package com.boss.mappeer;

import com.boss.pojo.Course;
import com.boss.pojo.Evaluations;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentMapper {


    // 根据id查询已选课程
    @Select("select * from courses where user_id = #{id}")
    List<Course> getCourseById(Integer id);
    // 根据id查询历史评教
    @Select("select * from evaluations where student_id = #{id}")
    List<Evaluations> getEvaluationList(Integer id);


    // 添加评教
    @Insert("insert into evaluations(rating,comments,submitted_time,course_id,student_id) values(#{rating},#{comments},now(),#{courseId},#{studentId})")
    void addEvaluation(Evaluations evaluations);

    //根据studentId和courseId查询对应评教
    @Select("select * from evaluations where student_id = #{studentId} and course_id = #{courseId}")
    Evaluations getEvaluation(Integer studentId, Integer courseId);
}
